<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\card\controller;

class IndexV2 extends \app\ApiRest
{
    protected $noNeedLogin = ["configV2"];
    protected $modelUser;
    protected $modelUserInfo;
    protected $modelCollection;
    protected $modelCompany;
    protected $modelConfig;
    protected $app;
    public function __construct(\think\App $app)
    {
        parent::__construct($app);
        $this->app = $app;
        $this->modelUser = new \app\card\model\User();
        $this->modelUserInfo = new \app\card\model\UserInfo();
        $this->modelCollection = new \app\card\model\Collection();
        $this->modelCompany = new \app\card\model\Company();
        $this->modelConfig = new \app\card\model\Config();
    }
    public function config()
    {
        $data = longbingGetAppConfig($this->_uniacid);
        unset($data["auth_code"]);
        $exist = \think\facade\Db::query("show tables like \"%longbing_card_config%\"");
        $auth_info = false;
        $cardauth2_config_exist = \think\facade\Db::query("show tables like \"%longbing_cardauth2_config%\"");
        if(!empty($exist) && !empty($cardauth2_config_exist)) {
            $auth_info = \think\facade\Db::name("longbing_cardauth2_config")->where([["modular_id", "=", $this->_uniacid]])->find();
        }
        $data["is_pay_shop"] = 1;
        if($auth_info && isset($auth_info["pay_shop"]) && $auth_info["pay_shop"] == 0) {
            $data["is_pay_shop"] = 0;
        }
        if(isset($data["btn_talk"]) && !$data["btn_talk"]) {
            $data["btn_talk"] = "面议";
        }
        $data["tabBar1"] = [];
        $data["tabBar1"] = \longbingcore\permissions\Tabbar::all($this->_uniacid, $this->_user_id);
        $pluginAuth = longbingGetPluginAuth($this->_uniacid, $this->_user_id, $auth_info);
        $data = array_merge($data, $pluginAuth);
        $data = \longbingcore\tools\LongbingArr::delBykey($data, ["web_manage_meta_config", "wx_appid", "wx_tplid", "update_time", "create_time", "app_secret", "appid", "aliyun_sms_access_key_id", "aliyun_sms_access_key_secret", "coupon_pass", "corpsecret", "coupon_pass", "order_pwd", "mini_template_id"]);
        $config_model = new \app\card\model\DefaultSetting();
        $DefaultSetting = $config_model->settingInfo(["uniacid" => $this->_uniacid], "primaryColor,subColor,share_more");
        $data["primaryColor"] = !empty($DefaultSetting["primaryColor"]) ? $DefaultSetting["primaryColor"] : "#19c865";
        $data["subColor"] = !empty($DefaultSetting["subColor"]) ? $DefaultSetting["subColor"] : "#f86c53";
        $data["share_more"] = $DefaultSetting["share_more"];
        return $this->success($data);
    }
    public function configV2()
    {
        $data = longbingGetAppConfig($this->_uniacid);
        unset($data["auth_code"]);
        $exist = \think\facade\Db::query("show tables like \"%longbing_card_config%\"");
        $auth_info = false;
        $cardauth2_config_exist = \think\facade\Db::query("show tables like \"%longbing_cardauth2_config%\"");
        if(!empty($exist) && !empty($cardauth2_config_exist)) {
            $auth_info = \think\facade\Db::name("longbing_cardauth2_config")->where([["modular_id", "=", $this->_uniacid]])->find();
        }
        $data["is_pay_shop"] = 1;
        if($auth_info && isset($auth_info["pay_shop"]) && $auth_info["pay_shop"] == 0) {
            $data["is_pay_shop"] = 0;
        }
        if(isset($data["btn_talk"]) && !$data["btn_talk"]) {
            $data["btn_talk"] = "面议";
        }
        $data["tabBar1"] = [];
        $config_model = new \app\card\model\DefaultSetting();
        $DefaultSetting = $config_model->settingInfo(["uniacid" => $this->_uniacid], "primaryColor,subColor,share_more");
        $data["primaryColor"] = !empty($DefaultSetting["primaryColor"]) ? $DefaultSetting["primaryColor"] : "#19c865";
        $data["subColor"] = !empty($DefaultSetting["subColor"]) ? $DefaultSetting["subColor"] : "#f86c53";
        $data["share_more"] = $DefaultSetting["share_more"];
        return $this->success($data);
    }
}

?>